home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Free Software Collection: Marty 1
/
FM Towns Marty 1 Free Software Collection.iso
/
tool
/
book
/
src
/
main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-11-11
|
5KB
|
215 lines
/*
* <<< ひみつのBook >>>
*
* High Speed Text Viewer for FM-TOWNS
*
* presented by MIYAZAKI & sugi 1990,91,92,93
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <egb.h>
#include <mos.h>
#include <fmc.h>
#include <msdos.cf>
#include <system.cf>
#include "menu_evt.h"
#include "init.h"
#include "book.h"
#include "lib.h"
#include "doslib.h"
#include "snd.h"
#include "keyio.h"
#include "cons.h"
#include "mouse.h"
#ifdef VSYNC
# include "vsync.h"
#endif
/* 外部ファイルにあるルーチン */
extern void dsp_main(char *file); /* テキスト表示のメイン */
extern void set_vector(void); /* ハードエラーベクタの設定 */
extern void reset_vector(void); /* ハードエラーベクタの復帰 */
extern char *param(char *path); /* パラメータのディレクトリに移動 */
static char moswork[MosWorkSize]; /* mouseライブラリ用 */
static char sndwork[SndWorkSize]; /* snd ライブラリ用 */
char *config = NULL; /* BOOK.CFG */
const cct[] = /* 色テーブル */
{
0x00000000, 0x11111111, 0x22222222, 0x33333333,
0x44444444, 0x55555555, 0x66666666, 0x77777777,
0x88888888, 0x99999999, 0xAAAAAAAA, 0xBBBBBBBB,
0xCCCCCCCC, 0xDDDDDDDD, 0xEEEEEEEE, 0xFFFFFFFF
};
void _mwcall_onexit_fcns(void)
{
/* atexit() を使わない */
}
int main(int argc, char *argv[])
{
int i;
char *file = NULL;
char *p;
char crrdir[256];
/* パラメータとオプションの解釈 */
for (i = 1; i < argc; i++)
{
p = argv[i] ;
if (*p == '/' || *p == '-')
{
p++;
switch (toupper(*p))
{
case 'C': /* BOOK.CFG の位置 */
if (*(p+1) != '\0')
config = p+1;
goto next;
case 'V': /* version */
_strcats(80, crrdir, "book.exp v",
_version, " / ", date, " / ", timestamp, "\n", NULL);
write(1, crrdir, strlen(crrdir));
exit(0);
}
}
else
file = p;
next: continue;
}
/* 致命的エラー割り込みの再設定 */
set_vector();
/* BOOK.EXP のパスリストを作成 */
strcpy(crrdir, argv[0]);
if ((p = jstrrchr(crrdir, '\\')) == NULL &&
(p = strchr(crrdir, ':')) == NULL)
crrdir[0] = '\0';
else
*++p = '\0';
/* コンフィグファイルを読む */
if (config == NULL &&
(config = (char *)malloc( strlen(crrdir) + 16)) != NULL)
{
strcpy(config, crrdir);
strcat(config, CONFIG_FILE);
}
if (config != NULL)
configuration(config);
/* 指定されていない場合の onsei.dic のフルパス作成 */
if (setup.onsei_dic == NULL &&
(setup.onsei_dic = (char *)malloc(strlen(crrdir) + 16)) != NULL)
{
strcpy(setup.onsei_dic, crrdir);
strcat(setup.onsei_dic, ONSEI_DIC);
}
/* 起動時のカレント・ディレクトリを退避 */
getdir(crrdir);
if ((p = jstrrchr(crrdir, '\\')) != NULL && strlen(crrdir) > 3)
*p = '\0'; /* 余計な \ をつぶす */
chdrv(*crrdir - 'A');
/* オプションによるファイル指定は特別処理 */
if ((p = param(file)) != NULL)
file = p;
/* 画面の初期化 */
EGB_init(gwork, EgbWorkSize);
setup.palette.text2 = setup.palette.text;
setup.palette.text2.color = 2;
init_screen();
#ifdef VSYNC
/* VSYNC割り込みライブラリの初期化 */
VSYNC_init();
#endif
SND_init(sndwork);
SND_elevol_mute(0x33);
/* マウスの初期化 */
MOS_start(moswork, MosWorkSize);
MOS_resolution(0, 3);
MOS_resolution(1, 3);
MOS_writePage(1);
MOS_horizon(MIN_HORIZON, (max_horizon = MAX_HORIZON2));
MOS_vertical(MIN_VERTICAL, MAX_VERTICAL);
mos_ptn_init();
set_mos_ptn(MOSCSR_FINGER);
MOS_disp(MOS_ON);
ctblset(_CHR_COL, _BAK_COL);
#ifdef VSYNC
#else
/* FM音源割り込みの準備 */
SND_fm_timer_a_set(0, 1);
#endif
/* キーボードアサインの保存 */
kb_asign_push();
/* キーアドレス変換テーブルの準備 */
kb_setup_cnvtbl();
/* かな漢字変換使用宣言 */
KAN_start();
/* ONSEI.DIC の読み込み */
if (init_tree(setup.onsei_dic) != ERR)
can_use_snd = TRUE;
/* Main Loop を呼ぶ */
dsp_main(file);
/* 画面サイズの再設定 */
wide_screen(OFF);
vertical_screen(480);
/* かな漢字変換終了宣言 */
KAN_end();
/* キーボードアサインの復元 */
kb_asign_pop();
/* マウスとサウンドの終了宣言 */
MOS_end();
SND_elevol_mute(0x00);
SND_end();
#ifdef VSYNC
/* VSYNC割り込みライブラリの終了 */
VSYNC_end();
#else
/* FM音源割り込みの終了 */
SND_fm_timer_a_set(0, 1);
#endif
/* 起動時のカレント・ディレクトリへ復帰 */
chdrv(crrdir[0] - 'A');
chdir(crrdir);
/* 致命的エラー割り込みの再設定 */
reset_vector();
return 0;
}